package com.china08.yxyapi.repository.db;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.china08.yxyapi.entity.db.lessons.YxyLessonsSynchroLessonItem;

public interface YxyLessonsSynchroLessonItemRepository extends JpaRepository<YxyLessonsSynchroLessonItem, String> {

    List<YxyLessonsSynchroLessonItem> findByChapterId(String id);

    YxyLessonsSynchroLessonItem findById(String lessonId);

    List<YxyLessonsSynchroLessonItem> findByLessonIdAndStatusNot(String lessonId, Integer status);

    YxyLessonsSynchroLessonItem findTop1ByChapterIdAndStatusNotOrderByOrderNumDesc(String id, int i);

    Integer countByWeikeIdInAndLessonIdAndStatusNot(List<String> weikeIds, String lessonId, int i);

    @Query(value = "select max(order_num) from yxy_lessons.yxy_lessons_synchro_lesson_item where chapter_id = ?1 and status != -1", nativeQuery = true)
    Integer maxByChapterIdAndDelNot(String chapterId);

    Integer countByLessonIdAndStatusNot(String lessonId, int i);

    Integer countByChapterIdAndStatusNot(String chapterId, int i);

    Integer countByLessonIdAndIdInAndStatusNot(String lessonId, List<String> itemsIds, int i);

    List<YxyLessonsSynchroLessonItem> findByChapterIdAndStatusNot(String id, int i);

    List<YxyLessonsSynchroLessonItem> findByLessonIdAndChapterIdAndOrderNumGreaterThanAndStatusNot(String lessonId,
            String chapterId, Integer itemOrderNum, int i);

    List<YxyLessonsSynchroLessonItem> findByLessonId(String lessonId);

    List<YxyLessonsSynchroLessonItem> findByChapterIdOrderByOrderNumAsc(String id);

    List<YxyLessonsSynchroLessonItem> findByChapterIdAndStatusNotOrderByOrderNumAsc(String id, int i);

}
